/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Framework;
import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreException;
import javax.microedition.rms.RecordStoreNotOpenException;
/**
 *
 * @author WanbooUIT
 */
public class CStoreRMS 
{
    public static RecordStore rs;
    
    
    public static byte[] toByte(int _data)
    {
        return  String.valueOf(_data).getBytes();
        
    }
    
    public static void LoadDefault(String recordStoreName) throws RecordStoreException 
    {
        CStoreRMS.rs = RecordStore.openRecordStore(recordStoreName, true);
        try {
            if (rs.getNumRecords() == 0) 
            {
                 
                // first time: add new record

               
            } 
        } finally {
            // this MUST ALWAYS HAPPEN, no matter what
            rs.closeRecordStore();
        }
    }
    public static void saveData(String recordStoreName,int _id, byte[] content) throws RecordStoreException 
    {
        CStoreRMS.rs = RecordStore.openRecordStore(recordStoreName, true);
        try {
            if (rs.getNumRecords() == 3) {
                // first time: add new record
                switch (_id) 
                    {
                        

                    }
            } else {
                // subsequently: update existing record
                switch (_id) 
                    {
                       

                    }
                
                
            }
        } finally {
            // this MUST ALWAYS HAPPEN, no matter what
            rs.closeRecordStore();
        }
    }
    
    public static String readRecords(int Id) throws RecordStoreException 
    {
        CStoreRMS.rs = RecordStore.openRecordStore("BubbleBoom", true);
        try {
        if(rs.getNumRecords() != 0)
        {
            switch (Id) 
            {

            }
        }
        else
            return String.valueOf(1);
        } finally {
            // this MUST ALWAYS HAPPEN, no matter what
            rs.closeRecordStore();
        }
        return null;
    }
}
